﻿using System;
using System.Security.Cryptography;
using System.Text;

namespace ImgClip
{
    public class Encryptor
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <param name="secret"></param>
        /// <returns></returns>
        public static string HmacSha256(string data, string secret)
        {
            byte[] keyByte = Encoding.UTF8.GetBytes(secret);
            byte[] dataBytes = Encoding.UTF8.GetBytes(data);
            using var hmac256 = new HMACSHA256(keyByte);
            byte[] hashData = hmac256.ComputeHash(dataBytes);
            return Convert.ToBase64String(hashData);
        }
    }
}
